package cn.lili.modules.member.entity.dos;

import cn.lili.common.validation.Mobile;
import cn.lili.modules.member.entity.enums.AddressTypeEnum;
import cn.lili.mybatis.model.BaseSceneEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serial;

/**
 * 用户地址
 *
 * @author Chopper
 * @since 2020-02-25 14:10:16
 */
@Data
@TableName("li_user_address")
@ApiModel(value = "用户地址")
public class UserAddress extends BaseSceneEntity {

    @Serial
    private static final long serialVersionUID = 6579161483635152941L;

    @NotBlank(message = "收货人姓名不能为空")
    @ApiModelProperty(value = "收货人姓名")
    private String name;

    @Mobile
    @NotBlank(message = "手机号不能为空")
    @ApiModelProperty(value = "手机号码")
//    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String mobile;

    @NotBlank(message = "行政地址名称不能为空")
    @ApiModelProperty(value = "地址名称， '，'分割")
    private String consigneeAddressPath;

    @NotBlank(message = "行政地址id不能为空")
    @ApiModelProperty(value = "地址id，'，'分割 ")
    private String consigneeAddressIdPath;

    @ApiModelProperty(value = "详细地址")
    @NotBlank(message = "地址详细不能为空")
    @Size(max = 100, message = "详细地址长度不能超过100")
    private String detail;

    @ApiModelProperty(value = "是否为默认收货地址")
    private Boolean isDefault = false;

    @ApiModelProperty(value = "地址别名")
    @Size(max = 20, message = "地址别名长度不能超过20")
    private String alias;

    @ApiModelProperty(value = "经度")
    @Pattern(regexp = "^(-?\\d+)(\\.\\d+)?$", message = "经度格式不正确")
    private String lon;

    @ApiModelProperty(value = "纬度")
    @Pattern(regexp = "^(-?\\d+)(\\.\\d+)?$", message = "纬度格式不正确")
    private String lat;

    /**
     * @see AddressTypeEnum
     */
    @ApiModelProperty(value = "地址类型,用于店铺，供应商等地址区分 发货地址，退货地址，自提点等", allowableValues = "NORMAL,RECEIVE,SEND,SELF_PICKUP")
    private String type = AddressTypeEnum.NORMAL.name();

}